<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="app" class="form-grap">
        <button @click="subone"> 
            -
         </button>
        <span>{{number}}</span>
        <button @click="addone"> 
            +
         </button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                number: 1
            },
            methods: {
                subone: function() {
                    if (this.number > 0) {
                        this.number--;
                        console.log("sub");
                    } else {
                        alert("不能小于0");
                    }

                },
                addone: function() {
                    if (this.number < 10) {
                        this.number++;
                        console.log("add");
                    } else {
                        alert("不能大于10");
                    }
                }
            }
        })
    </script>

</body>

</html>
<!--v-on 可以用@代替-->